package com.lap.framework.junit.domain.methods;

import static com.lap.framework.junit.shared.tool.Constant.*;

import com.lap.framework.junit.domain.valueobject.JMethod;

public class PostMethod implements AbstractMethod {

  @Override
  public String execute(JMethod methodInfo) {
    StringBuilder result = new StringBuilder(128);

    if (!methodInfo.isArgMap()) result.append(getParamMap(methodInfo));

    result.append(TAB2).append(formatter(PERFORM, "post", methodInfo.getUri()));
    if (methodInfo.isArgMap()) result.append(".content(map.getJson())");
    else result.append(".content(_content)");

    result.append(CONTENT_TYPE).append(WRAP);
    result.append(TAB6).append(EXPECT_STATUS_IS_OK).append(WRAP);
    result.append(TAB6).append(formatter(EXPECT_JSON, getCode(methodInfo))).append(WRAP);

    return result.toString();
  }
}
